<%--
  Created by IntelliJ IDEA.
  User: 22531
  Date: 2021/5/30
  Time: 18:41
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>studentInformation</title>
    <link rel="stylesheet" type="text/css" href="/easyui/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="/easyui/themes/icon.css">
    <script type="text/javascript" src="/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="/js/datagrid-export.js"></script>
    <script src="/easyui/locale/easyui-lang-zh_CN.js"></script>

</head>
<body>

<div class="easyui-panel" data-options="fit:true,border:false">
    <table id="dg" class="easyui-datagrid" style="width: auto;height: auto"
           data-options="
                        url: '/stu/getGrade?id=${sessionScope.stu.id}',
                        title:'学生选课查询',
                        autoRowHeight: true,
                        toolbar: '#stuScTb',
                        fitColumns:true,
                        rownumbers:true,
                        ">
        <thead>
        <tr>
            <th field="course_name" align="center">课程名称</th>
            <th field="course_id" align="center">课程id</th>
            <th field="grade" align="center" data-options="formatter: function(value,row,index){
                           if(row.grade==0){
                               return '暂无分数';
                           }else {
                               return value;
                           }
                        }">分数</th>
        </tr>
        </thead>
    </table>
</div>
<div id="stuScTb" style="height:auto;width: auto">
    <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="myReload()">刷新</a>
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-excel'" onclick="$('#dg').datagrid('toExcel','dg.xls')">ExportToExcel</a>
    <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-pdf'" onclick="$('#dg').datagrid('print','DataGrid')">ExportToPDF</a>

</div>
<script type="text/javascript">
    function myReload() {
        $('#dg').datagrid('reload');
    }
    function toPdf(){
        var body = $('#allStuInfo').datagrid('toArray');
        var docDefinition = {
            content: [{
                table: {
                    headerRows: 1,
                    widths: ['auto','*','*'],//注意要与列数对应
                    body: body
                }
            }]
        };
        pdfMake.createPdf(docDefinition).open();
    }
</script>
</body>
</html>
